package org.ns.example.controller;

import org.ns.example.pojo.ResponseEntity;
import org.ns.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;
    // 进行登录
    @RequestMapping("/login")
    public ResponseEntity login(String username, String password, HttpServletRequest request)  {
        return userService.login(username, password, request);
    }
    // 注销登录
    @RequestMapping("/loginout")
    public ResponseEntity loginout(HttpServletRequest request) {
        request.getSession().invalidate();
        return ResponseEntity.newResponseEntity(0, "OK");
    }


}
